﻿using System;

class SortByStringLength
{
    //Exercise 5.
    //You are given an array of strings. Write a method that sorts the array by the length of its elements 
    //(the number of characters composing them).

    static void Main()
    {
        //string[] array = new string[] { "method", "ford", "ten", "hi", "zebra", "sequence"};

        //Declare your array
        Console.Write("Enter the length of the array N: ");
        int n = int.Parse(Console.ReadLine());
        string[] array = new string[n];

        //Initialize the array from the console        
        for (int i = 0; i < array.Length; i++)
        {
            Console.Write("Array [{0}]  ", i);
            array[i] = Console.ReadLine();
        }

        Array.Sort(array, (word1, word2) => (word1.Length).CompareTo(word2.Length));
        foreach (var word in array)
        {
            Console.WriteLine(word);
        }

    }
}

